import { TBY } from '@/api/config/servicePort'
import http from '@/api'
import { TbyTypeLevel } from './interface'
import { ResPage } from '@/api/interface'

// 树型表格数据
export function treeTableList() {
  return http.get<ResPage<TbyTypeLevel.Record>>(TBY + '/typeLevelInfo/treeTableList')
}

// 下拉选
export function optionsTypeLevel(name: string) {
  return http.get<TbyTypeLevel.TreeType[]>(TBY + '/typeLevelInfo/options', { name })
}

// 动植物分级详情
export const getTypeLevelDetail = (id: number) => {
  return http.get<Partial<TbyTypeLevel.Form>>(TBY + `/typeLevelInfo/get`, { id }, { loading: false })
}

// 新增或修改动植物分级
export const saveOrUpdateTypeLevel = (params: Partial<TbyTypeLevel.Form>) => {
  return http.post(TBY + `/typeLevelInfo/saveOrUpdate`, params)
}

// 删除动植物分级
export const removeTypeLevel = (id: number) => {
  return http.delete(TBY + `/typeLevelInfo/delete`, { id })
}
